trigger trgAfterEntInsUpd on Entitlement__c (after update, after insert, after delete) {
    if (trigger.isInsert) 
    {
/*        List<Entitlement__c> oldDefArr = new List<Entitlement__c>([
              Select Id,IsDefault__c From Entitlement__c Where 
              (Support_Program__c In :DefEntCrossTrigger.DirtySPs) And (IsDefault__c=True) 
              And (Id Not In :trigger.newMap.keySet())]);
             
        for(Entitlement__c e:oldDefArr) { e.IsDefault__c = false; }
        
        update oldDefArr;
*/
        List<Entitlement__c> newDefEntsArr = new List<Entitlement__c>(
            [Select Id,IsDefault__c From Entitlement__c Where
            IsDefault__c=True And (Id In :trigger.newMap.keySet())]);
        update newDefEntsArr;
    }
    
    if (trigger.isUpdate) 
    {
       if (!DefEntCrossTrigger.InEntUpdateTrigger) 
       {
          //Set<Id> DirtySPs = new Set<Id>();
          for(Entitlement__c e:trigger.new) { DefEntCrossTrigger.DirtySPs.add(e.Support_Program__c); }
          for(Entitlement__c e:trigger.old) { DefEntCrossTrigger.DirtySPs.add(e.Support_Program__c); }
          DefEntCrossTrigger.FixSPDefEntHints(DefEntCrossTrigger.DirtySPs);
          DefEntCrossTrigger.DirtySPs.clear();
       }
    }
    
    if (trigger.isDelete) 
    {
          for(Entitlement__c e:trigger.old) { DefEntCrossTrigger.DirtySPs.add(e.Support_Program__c); }
          DefEntCrossTrigger.FixSPDefEntHints(DefEntCrossTrigger.DirtySPs);
          DefEntCrossTrigger.DirtySPs.clear();
    }
    
}